<?php
/**
 * Created by PhpStorm.
 * User: KaZeline
 * Date: 15-9-9
 * Time: 上午9:20
 */
use Api\Ctrip;
switch ($_POST['action']) {
    case 'SenicSearch':
        include '../api/ctrip/ctrip_test.php';
        $ctrip =  new Ctrip();
        $Get_lID = $ctrip->TicketSenicSpotSearch($_POST['zone'],$_POST['c_id']+0,$_POST['page']+0, 15); //print_r($Get_lID);
        $total   = $Get_lID['Count'];
        if ($Get_lID) {
            foreach ($Get_lID['list'] as $list) {
                $html_list .= <<<HTML
        <tr>
            <td><input name="id[]" type="checkbox" value="{$list['id']}" /></td>
            <td>{$list['id']}</td>
            <td><a target="_blank" href="detail.php?channel=ctrip&id={$list['id']}">{$list['Name']}</a></td>
            <td><input type="button" value="导入"></td>
        </tr>
HTML;
            }
        }
        echo json_decode(array(
            'html'=>$html_list,
            'total'=>$total
        ));
        break;
    case 'import':
        if($_POST['partner']=='ctrip') {
            include 'Ctrip.php';
            $ctrip = new Ctrip();
            $data = $ctrip->TicketSenicSpotInfo($_POST['c_id']+0);
            $ret = Ctrip::raw_post('http://dev.12301.cc/module/api_import/handler_ctrip.php', json_encode($data));
        }else if($_POST['partner']=='lvmama') {
            include 'Lvmama.php';
            $ctrip = new Api\LvMaMa();
            $data = $ctrip->TicketSenicSpotInfo($_POST['c_id']+0);
            $ret = Api\LvMaMa::raw_post('http://dev.12301.cc/module/api_import/handler_lvmama.php', json_encode($data));
        }
        else if($_POST['partner']=='qunar') {
            include '/var/www/html/new/d/module/wxh/api_import/qunar2B_demo.php';
            if(empty($_POST['flag']))exit('{"code":"供应商为空"}');
            $ctrip = new Qunar2B();
            $data = $ctrip->TicketSenicSpotInfo($_POST['c_id']+0,$_POST['flag']);
            $ret =Qunar2B::raw_post('http://dev.12301.cc/module/api_import/qunar.php', json_encode($data));
        }
        echo $ret;
        break;
    default:
        # code...
        break;
}
@$GLOBALS['le']->close();
exit;